fix: race condition on get when add received after informer cache read - alt 1#3238
Closed
csviri wants to merge 9 commits intooperator-framework:mainfrom
Closed
fix: race condition on get when add received after informer cache read - alt 1#3238csviri wants to merge 9 commits intooperator-framework:mainfrom
csviri wants to merge 9 commits intooperator-framework:mainfrom
Conversation
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…he - alt 1 Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses a suspected rare race condition in informer cache access by adjusting ManagedInformerEventSource#get to re-read the informer cache in a specific edge case, and strengthening an integration test reconciler to detect stale/incorrect secondary resource reads.
Changes:
- Update
ManagedInformerEventSource#getto handle the “temp cache present but obsolete + informer cache initially empty” scenario by re-reading the informer cache. - Extend the caching/filtering update test reconciler to perform two successive server-side applies and validate the cached secondary resource reflects the latest resource version.
- Adjust debug logging around cache selection decisions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/cachingfilteringupdate/CachingFilteringUpdateReconciler.java | Enhances the test reconciler to apply/update a secondary ConfigMap twice and assert the cache reflects the latest resource version. |
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java | Implements an “informer cache re-read” fallback to mitigate an extremely rare ordering/race issue between temporary and informer caches, and updates related logs. |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+55
to
+56
| if (!cachedCM | ||
| .orElseThrow() |
Comment on lines
+221
to
+222
| "Resource found in temp cache: {}, or older, in temporary cache. Found in informer cache" | ||
| + " {}, for Resource ID: {}", |
| resourceID, | ||
| res.isEmpty()); | ||
| if (res.isEmpty()) { | ||
| // re-reading resource from informer cache since an add even might have received |
Comment on lines
+211
to
+215
| if (res.isEmpty()) { | ||
| // re-reading resource from informer cache since an add even might have received | ||
| // after the first read. | ||
| return cache.get(resourceID); | ||
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.